package com.kimoge.spring6.validation.methodtwo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.BindException;
import org.springframework.validation.Validator;

/**
 * @author kimoge
 * @date 2025/8/30
 * @description
 */
@Service
public class MyService2 {
    @Autowired
    private Validator validator;

    public boolean validatorByValidator(Person person) {
        BindException bindException = new BindException(person, person.getName());
        validator.validate(person, bindException);
        return bindException.hasErrors();
    }
}
